# 
# //----------------------------------------------------------------//
# // this was shawn's demo for sync the clock source from sc module to sv testbench 
# //----------------------------------------------------------------//
#
TRACE_OPT=
ifdef TRACE
TRACE_OPT=+UVMC_COMMAND_TRACE
endif

VCS_BITS=-full64

DEMO ?=sc_main

DPI_HOME ?= ./lib/c_dpi
SC_HOME ?=./sysc
SC_INC ?= $(SC_HOME)/include
SC_SRC ?= $(SC_HOME)/src

VERBOSE=+UVM_VERBOSITY=UVM_MEDIUM

SYSCAN = syscan -cpp g++ -cc gcc $(VCS_BITS) \
    -cflags -g -cflags -DVCS -cflags -I. \
    -tlm2 -cflags -I${VCS_HOME}/etc/systemc/tlm/include/tlm/tlm_utils \
    -cflags -I$(SC_INC) -cflags -I$(DPI_HOME) \
    -cflags -DVCSMX

VLOGAN = vlogan -q $(VCS_BITS) -sverilog\
		 -timescale=1ns/1ps

VCS_ELAB = vcs -q -sysc=deltasync -lca $(VCS_BITS) -sysc -timescale=1ns/1ps

VCS = vcs -q -sysc=deltasync -lca $(VCS_BITS) \
    -sverilog +incdir+${UVM_HOME}/src ${UVM_HOME}/src/uvm_pkg.sv \
    +incdir+${UVMC_HOME}/src/connect/sv \
    ${UVMC_HOME}/src/connect/sv/uvmc_pkg.sv -timescale=1ns/1ps -sysc

COMPILE_UVM_DPI = \
    g++ -c -fPIC -DVCS -I$(VCS_HOME)/include -I$(DPI_HOME) -I ${DPI_HOME}/uvm_dpi.c \
        -o uvm_dpi.o; \
    g++ -shared -o uvm_dpi.so uvm_dpi.o

SIMV = $(COMPILE_UVM_DPI); ./simv -q -sv_lib uvm_dpi


.PHONY: compile, sim, syscan, vlogan, elab , clean

syscan:
	$(SYSCAN) $(SC_SRC)/scModule.cc $(SC_HOME)/$(DEMO).cc -debug_all
vlogan:
	$(VLOGAN) -f file.lst +define+UVM_OBJECT_MUST_HAVE_CONSTRUCTOR 
elab:
	$(VCS_ELAB) sv_top sc_main -debug_all


compile: syscan, vlogan, elab
	
#	$(SYSCAN) $(DEMO).cc -debug_all
#	$(VLOGAN) -f file.lst +define+UVM_OBJECT_MUST_HAVE_CONSTRUCTOR 
#	$(VCS_ELAB) sv_top sc_main -debug_all

sim: run

run:	
	$(SIMV) $(TRACE_OPT) $(ARGS) +UVM_NO_RELNOTES 2>&1 |tee $(EXAMPLE)_run.log

clean:
	@rm -rf csrc
